<?php
//var_dump(get_query_var('page')); die; 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */ 
if(isset($_GET['t']) && $_GET['t'] || get_query_var('page')) { 
	$page = get_query_var('page'); 
	
	switch($_GET['t']){
		case  1 :  $ftype = 'hinh-goc'; break; 
		case  2 :  $ftype = 'album-cuoi'; break; 
		case  3 :  $ftype = 'hinh-tiec'; break; 
		case  4 :  $ftype = 'hinh-le'; break; 
		case  1 :  $ftype = 'hinh-goc'; break; 
		default:   $ftype = 'all'; break; 
	}
 // get content by ajax 
            global $wpdb;
                        
			$user_ID = get_current_user_id();

			$thumb_path = my_get_home_path() . "/media/user_{$user_ID}/{$ftype}/thumbs/";

			$allthumbs = scandir($thumb_path);
		
			foreach($allthumbs as $key=>$value){
				if($key == 0  || $key == 1 || $key == 2) unset($allthumbs[$key]);
			}
			$allthumbs = array_values($allthumbs);
			//pagination 
			 
			$perpage = 16; 
			$start = ($page - 1) * $perpage; 
			$end   = $start +  $perpage; 
            if (is_array($allthumbs) && $end < count($allthumbs)) {
                for ($i = $start; $i < $end ; $i++ ) {
					$imgurl = get_site_url() . "/media/user_{$user_ID}/{$ftype}/full/" . $allthumbs[$i];
					list($width, $height, $type, $attr) = getimagesize($thumb_path.$allthumbs[$i]);
					$height = $height ; 
					$width = 200;
				?>
				<div class="item <?php echo $class ?>">
                    <div class="view second-effect">
                        <img height="<?php echo $height ?>" width="<?php echo $width ?>" src="<?php echo $imgurl ?>"  alt="" />
                         <div class="mask">
                            <a href="javascript:;" class="info" data="<?php echo $i+1 ?>">Read More</a>
                        </div>
                    </div>
                </div>  
				<?php 
				}
            }else {
				die; 
				}
}
?>
